#include "CheckBtn.h"

CCheckBtn::CCheckBtn(UINT nID):CBmpBtn(nID)
{
	Init();
}

CCheckBtn::CCheckBtn(wstring strCaption,UINT nID)
:	CBmpBtn(strCaption,nID)
{
	Init();
}

CCheckBtn::CCheckBtn(DWORD dwStyle,wstring strCaption, const CRect &rc, UINT nID)
:	CBmpBtn(dwStyle, strCaption,rc, nID)
{
	Init();
}

CCheckBtn::CCheckBtn(DWORD dwStyle, wstring strCaption, int x, int y, int cx, int cy, UINT nID)
:	CBmpBtn(dwStyle, strCaption, x, y, cx, cy, nID)
{
	Init();
}

CCheckBtn::~CCheckBtn(void)
{

}

void CCheckBtn::Init()
{
	m_nIconNum = 2;
	m_bChecked = FALSE;
}

void CCheckBtn::Paint(CDC* pDC)
{
	if(m_rcControl.IsRectEmpty())
	{
		return ;
	}

	if(!IsVisible())
	{
		return;
	}

	//PaintBackGnd(pDC);

	int nIndex = 0;
	COLORREF clrOld = RGB(255,255,255);

	if(2 == m_nIconNum)
	{
		if(m_bChecked)
		{
			nIndex = 0;
			clrOld = pDC->SetTextColor(m_clrTxtNormal);
		}
		else
		{
			nIndex = 1;
			clrOld = pDC->SetTextColor(m_clrTxtActive);
		}
	}

	if(m_pImgLstBtn)
	{
		m_pImgLstBtn->Draw(pDC,nIndex,m_rcControl.TopLeft());
	}
	if(m_strCaption.length())
	{
		BEGIN_FONT_SELECTION

		pDC->SetBkMode(TRANSPARENT);
		CRect rcTmp = m_rcControl;
		rcTmp.top += m_szTextOffset.cy;
		rcTmp.left += m_szTextOffset.cx;
		pDC->DrawText(m_strCaption.c_str(),m_strCaption.size(),rcTmp,m_dwAlign);
		pDC->SetTextColor(clrOld);

		END_FONT_SELECTION
	}
}

